package com.my.chapter15;

public class practice23 {
    public static void main(String[] args) {
        Foo<Integer> f = new Foo<Integer>(new IntegerFactory(),6);
        f.print();
    }
}

interface FactoryI<T> {
    T create(int arg);
}

class Foo<T> {
    private T x;
    public Foo(FactoryI<T> factory,int arg) {
        x = factory.create(arg);
    }
    public void print(){
        System.out.println(x);
    }
}

class IntegerFactory implements FactoryI<Integer> {

    @Override
    public Integer create(int arg) {
        return new Integer(arg);
    }
}
